package com.sunday.factory.factory;

import com.sunday.factory.constant.FileTypeConstant;
import com.sunday.factory.parser.type.IRuleConfigParser;
import com.sunday.factory.parser.type.impl.JsonRuleConfigParser;
import com.sunday.factory.parser.type.impl.XmlRuleConfigParser;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName RuleConfigParserFactory
 * @Author JiangHai
 * @Date 2021/9/5 19:09
 **/
public class RuleConfigParserFactory {

    private static final Map<String,IRuleConfigParser> TYPE_ITEM_MAPPING = new HashMap<>(16);

    static {
        TYPE_ITEM_MAPPING.put(FileTypeConstant.JSON,new JsonRuleConfigParser());
        TYPE_ITEM_MAPPING.put(FileTypeConstant.XML,new XmlRuleConfigParser());
    }

    public static IRuleConfigParser createParser(String msg) {
        return TYPE_ITEM_MAPPING.get(msg);
    }
}
